package domain.service;

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.net.URL;
import java.nio.charset.Charset;


import com.google.appengine.api.urlfetch.URLFetchService;
import com.google.appengine.api.urlfetch.URLFetchServiceFactory;

public class CheckDomain {
	public static Boolean CheckDomain(String naString)
	{
		String content = "";
		try {
			
			URL dataURL = new URL("http://"+naString);
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(dataURL.openStream(), Charset.forName("UTF8")));
			
			while(1==1)
			{
				String str = reader.readLine();
				if(str==null) break;
				content+=str;
				
			}
	
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		try {
			
			URLFetchService fetcher = URLFetchServiceFactory.getURLFetchService();
			URL dataURL = new URL("http://www."+naString);
			
			BufferedReader reader = new BufferedReader(new InputStreamReader(dataURL.openStream(), Charset.forName("UTF8")));
			
			while(1==1)
			{
				String str = reader.readLine();
				if(str==null) break;
				content+=str;
				
			}
	
		} catch (Exception e) {
			
			e.printStackTrace();
		}
		if(content.equals(""))
		{
			return false;
		} else {
			return true;
		}
	}
	public static void main( String args[])
	{
		new CheckDomain();
	}
}
